• Go to and drag out two Random Integer commands.
  • Drop them ABOVE the goal_star shape, inside the interval event.
  • Rename them rand_x and rand_y.
  • Change the rand_x range to ( -250, 250). Change the rand_y range to (-100, 250).
  • Now replace goal_star's x-coordinate with rand_x and its y-coordinate with rand_y.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("moon") sprite = codesters.Sprite("hedgehog") sprite.go_to(0, -210) def left(): sprite.turn_left(20) stage.event_left_key(left) def right(): sprite.turn_right(20) stage.event_right_key(right) def up(): sprite.move_forward(575) stage.wait(0.1) sprite.go_to(0, -210) stage.event_up_key(up) def interval(): goal_star = codesters.Star(0, 0, 5, 15, "yellow") # add any other actions... stage.event_interval(interval, 2)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)